package com.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DbHelper extends SQLiteOpenHelper{

	
	private static final String TABLE_NAME1="note";
	public static final String KEY_ROWID = "_id";
	private static final String KEY_NAME="name";
	private static final String KEY_ITEM="content";
	private static final String KEY_NOTEBOOKID="notebookid";
	private static final String TABLE_CREATE1= "create table if not exists " + TABLE_NAME1 + " (" + KEY_ROWID +
												" integer primary key autoincrement, "
													+ KEY_NAME +" text not null,"
													+KEY_ITEM +" text not null,"
													+KEY_NOTEBOOKID +" integer not null);";
	
	private static final String TABLE_NAME2="notebook";
	public static final String KEY_ROWID2 = "_id";
	private static final String KEY_NAME2="name";
	private static final String KEY_ITEM2="item";
	private static final String TABLE_CREATE2= "create table if not exists " + TABLE_NAME2 + " (" + KEY_ROWID2 +
												" integer primary key autoincrement, "
													+ KEY_NAME2 +" text not null,"
													+KEY_ITEM2 +" text not null);";
	
	public DbHelper(Context context, String name, CursorFactory factory,
			int version) {
		
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		
		db.execSQL(TABLE_CREATE1);
		db.execSQL(TABLE_CREATE2);
	    //db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME1);
		//db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME2);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		//db.execSQL("DROP TABLE IF EXISTS " + TABLE_CREATE1);
		onCreate(db);
	}

}
